<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<f:view contentType="text/html">
	<h:head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet"
			href="${request.contextPath}/resources/css/style.css" type="text/css"
			media="screen" />
		<link rel="stylesheet"
			href="${request.contextPath}/resources/css/styleButton.css"
			type="text/css" media="screen" />
		<link rel="shortcut icon"
			href="${request.contextPath}/resources/img/favicon.ico" />
		<title><ui:insert name="title"></ui:insert></title>
	</h:head>
	<h:body>
		<div id="page">
			<div id="menu">
				<ui:insert name="header">
					<center>
						<ui:include src="/template/commonHeader.xhtml" />
					</center>
				</ui:insert>
			</div>
			<div id="line" />
			<div id="content">
				<h:form id="formIndexLesson">
					<br />
					<p:commandButton value="&nbsp;#{Button.add_new_lessons}"
						styleClass="addButton" update=":formAddLesson:panelGridAdd"
						action="#{studentLessonController.preparedAddingLesson}"
						oncomplete="dialogAdd.show();" />
					<p:commandLink value="Show All Lesson"
						update=":formLessonList:listDatatable"
						onclick="dialogLesson.show();" styleClass="commandLink" />
				</h:form>

				<h:form id="formListStudentLesson">
					<p:dataTable id="listDatatable" var="studentLessonList"
						value="#{studentLessonController.studentLessons}"
						style="width:94%; padding-top: 3px; padding-bottom: 3px; padding: 2%;  vertical-align: top;"
						draggableColumns="true" resizableColumns="true">

						<p:column
							sortBy="#{studentLessonList.teacherLesson.lesson.lesson_name}"
							headerText="LESSON NAME">
							<h:outputText
								value="#{studentLessonList.teacherLesson.lesson.lesson_name}" />
						</p:column>

						<p:column
							sortBy="#{studentLessonList.teacherLesson.lesson.lesson_code}"
							headerText="LESSON CODE">
							<h:outputText
								value="#{studentLessonList.teacherLesson.lesson.lesson_code}" />
						</p:column>

						<p:column sortBy="#{studentLessonList.teacherLesson.teacher.name}"
							headerText="TEACHER">
							<h:outputText
								value="#{studentLessonList.teacherLesson.teacher.name} #{studentLessonList.teacherLesson.teacher.surname}" />
						</p:column>

						<p:column headerText="STATUS" style="width:5%">
							<p:commandLink onclick="this.disabled=false;" disabled="false">
								<p:graphicImage library="img"
									name="lesson_#{studentLessonList.status_lesson}.png" />
							</p:commandLink>
						</p:column>
					</p:dataTable>
				</h:form>

				<h:form id="formAddLesson">
					<p:dialog header="Lesson Informatiom" id="dialogAdd"
						widgetVar="dialogAdd" resizable="true" modal="true"
						showEffect="explode" hideEffect="explode">
						<p:growl id="growlAdd" showDetail="true" sticky="true" />
						<p:panelGrid id="panelGridAdd" columns="2" cellpadding="4">
							<h:panelGroup>
								<h:outputText styleClass="outputText" value="Student : " />
								<h:outputText style="color:red; float: right" value=" * " />
							</h:panelGroup>
							<p:selectOneMenu
								value="#{studentLessonController.studentLesson.student}"
								requiredMessage="User cannot be null" required="true"
								style="width:200px;" effect="fold" filter="true"
								filterMatchMode="startsWith" converter="studentIdConverter">
								<f:selectItems value="#{studentController.studentList}"
									var="students" itemLabel="#{students.name}"
									itemValue="#{students}" />
							</p:selectOneMenu>

							<h:panelGroup>
								<h:outputText styleClass="outputText" value="Lesson : " />
								<h:outputText style="color:red; float: right" value=" * " />
							</h:panelGroup>
							<p:selectOneMenu
								value="#{studentLessonController.studentLesson.teacherLesson}"
								requiredMessage="Lesson cannot be null" required="true"
								style="width:200px;" effect="fold" filter="true"
								filterMatchMode="startsWith"
								converter="teacherLessonIdConverter">
								<f:selectItems value="#{teacherLessonController.teacherLessons}"
									var="teacherLessons"
									itemLabel="#{teacherLessons.lesson.lesson_name}"
									itemValue="#{teacherLessons}" />
							</p:selectOneMenu>

						</p:panelGrid>

						<p:separator />
						<p:separator />
						<p:commandButton value="&nbsp;#{Button.add_button}"
							update=":formListStudentLesson:listDatatable, growlAdd, dialogAdd"
							actionListener="#{studentLessonController.save}"
							oncomplete="dialogAdd.hide()" icon="ui-icon-disk">

						</p:commandButton>
						<p:commandButton value="&nbsp;#{Button.cancel_button}"
							update=":formListStudentLesson:listDatatable"
							oncomplete="dialogAdd.hide()" icon="ui-icon-circle-close" />
						<p:separator />
						<p:separator />
					</p:dialog>
				</h:form>

				<h:form id="formLessonList">
					<p:dialog header="Lesson List Dialog" widgetVar="dialogLesson"
						modal="true" showEffect="explode" hideEffect="explode" width="80%"
						styleClass="dialogFilter">
						<p:dataTable id="listDatatable" var="lessonList"
							value="#{teacherLessonController.teacherLessons}"
							style="width:98%; padding-top: 10px; padding-bottom: 10px; padding-left: 1%;  vertical-align: top;"
							paginator="true" rows="24"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							paginatorPosition="bottom" rowsPerPageTemplate="12,24,36,72"
							selection="#{teacherLessonController.teacherLesson}"
							rowKey="#{lessonList}" selectionMode="single"
							widgetVar="lessonTable"
							emptyMessage="No Lesson found with given criteria"
							filteredValue="#{teacherLessonController.filterTeacherLesson}"
							draggableColumns="false" resizableColumns="true">
							<p:ajax event="rowSelect"
								listener="#{teacherLessonController.onRowSelect}"
								update=":formLessonList:panelGrid"
								oncomplete="lessonDialog.show()" />

							<p:column sortBy="#{lessonList.teacher.name}"
								headerText="TEACHER">
								<h:outputText
									value="#{lessonList.teacher.name} #{lessonList.teacher.surname}" />
							</p:column>

							<p:column sortBy="#{lessonList.lesson.lesson_name}"
								headerText="LESSON NAME">
								<h:outputText value="#{lessonList.lesson.lesson_name}" />
							</p:column>

							<p:column sortBy="#{lessonList.lesson.lesson_code}"
								headerText="LESSON CODE">
								<h:outputText value="#{lessonList.lesson.lesson_code}" />
							</p:column>

						</p:dataTable>
						<p:separator />
						<p:commandButton value="&nbsp;Close"
							oncomplete="dialogLesson.hide()" icon="ui-icon-circle-close"
							style="margin-left: 50%;" />
						<p:separator />
					</p:dialog>

					<p:dialog header="Lesson Detail" widgetVar="lessonDialog"
						resizable="false" showEffect="explode" hideEffect="explode"
						styleClass="dialogback">
						<h:panelGrid id="panelGrid" columns="2" cellpadding="4">

							<f:facet name="header">
								<h:outputText
									value="#{teacherLessonController.teacherLesson.teacher.name} #{teacherLessonController.teacherLesson.teacher.surname}"
									style="font-weight:bold" />
							</f:facet>

							<h:panelGroup>
								<h:outputText value="Lesson Name  " />
								<h:outputText style="color:red; float: right" value=" : " />
							</h:panelGroup>
							<h:outputText
								value="#{teacherLessonController.teacherLesson.lesson.lesson_name}"
								style="font-weight:bold" />

							<h:panelGroup>
								<h:outputText value="Lesson Code  " />
								<h:outputText style="color:red; float: right" value=" : " />
							</h:panelGroup>
							<h:outputText
								value="#{teacherLessonController.teacherLesson.lesson.lesson_code}"
								style="font-weight:bold" />


							<h:panelGroup>
								<h:outputText value="Lesson Credit  " />
								<h:outputText style="color:red; float: right" value=" : " />
							</h:panelGroup>
							<h:outputText
								value="#{teacherLessonController.teacherLesson.lesson.credit}"
								style="font-weight:bold" />

							<h:panelGroup>
								<h:outputText value="Lesson Hour  " />
								<h:outputText style="color:red; float: right" value=" : " />
							</h:panelGroup>
							<h:outputText
								value="#{teacherLessonController.teacherLesson.lesson.hour}"
								style="font-weight:bold" />

							<h:panelGroup>
								<h:outputText value="Lesson Quota  " />
								<h:outputText style="color:red; float: right" value=" : " />
							</h:panelGroup>
							<h:outputText
								value="#{teacherLessonController.teacherLesson.lesson.quota}"
								style="font-weight:bold" />

							<h:panelGroup>
								<h:outputText value="Semester  " />
								<h:outputText style="color:red; float: right" value=" : " />
							</h:panelGroup>
							<h:outputText
								value="#{teacherLessonController.teacherLesson.lesson.semesters.semester_name}"
								style="font-weight:bold" />

						</h:panelGrid>

						<p:separator />
						<p:commandButton value="&nbsp;Close"
							oncomplete="lessonDialog.hide()" icon="ui-icon-circle-close"
							style="margin-left: 22%;" />
						<p:separator />
					</p:dialog>
				</h:form>
			</div>
			<div id="line" />
			<br />
			<div id="footer">
				<ui:insert name="footer">
					<ui:include src="/template/commonDock.xhtml" />
				</ui:insert>
			</div>
		</div>

		<script type="text/javascript">
			 	function handleTeacherRequest(xhr, status, args) {
		        	window.location = "${request.contextPath}/flows/actions/newteacher.jsf?execution=n0t55";
			 	}
			 	</script>

	</h:body>
</f:view>
</html>
